.class public Llt/farmis/libraries/externalgps/nmea/NmeaParser;
.super Ljava/lang/Object;
.source "NmeaParser.java"


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Llt/farmis/libraries/externalgps/nmea/NmeaParser$VTG;,
        Llt/farmis/libraries/externalgps/nmea/NmeaParser$RMC;,
        Llt/farmis/libraries/externalgps/nmea/NmeaParser$GGA;,
        Llt/farmis/libraries/externalgps/nmea/NmeaParser$SentenceParser;
    }
.end annotation


# static fields
.field private static final sentenceParsers:Ljava/util/Map;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/Map<",
            "Ljava/lang/String;",
            "Llt/farmis/libraries/externalgps/nmea/NmeaParser$SentenceParser;",
            ">;"
        }
    .end annotation
.end field


# instance fields
.field position:Llt/farmis/libraries/externalgps/GPSLocation;


# direct methods
.method static constructor <clinit>()V
    .locals 1

    .line 117
    new-instance v0, Ljava/util/HashMap;

    invoke-direct {v0}, Ljava/util/HashMap;-><init>()V

    sput-object v0, Llt/farmis/libraries/externalgps/nmea/NmeaParser;->sentenceParsers:Ljava/util/Map;

    return-void
.end method

.method public constructor <init>()V
    .locals 3

    .line 118
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 116
    new-instance v0, Llt/farmis/libraries/externalgps/GPSLocation;

    invoke-direct {v0}, Llt/farmis/libraries/externalgps/GPSLocation;-><init>()V

    iput-object v0, p0, Llt/farmis/libraries/externalgps/nmea/NmeaParser;->position:Llt/farmis/libraries/externalgps/GPSLocation;

    .line 119
    sget-object v0, Llt/farmis/libraries/externalgps/nmea/NmeaParser;->sentenceParsers:Ljava/util/Map;

    new-instance v1, Llt/farmis/libraries/externalgps/nmea/NmeaParser$GGA;

    invoke-direct {v1, p0}, Llt/farmis/libraries/externalgps/nmea/NmeaParser$GGA;-><init>(Llt/farmis/libraries/externalgps/nmea/NmeaParser;)V

    const-string v2, "GGA"

    invoke-interface {v0, v2, v1}, Ljava/util/Map;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    .line 120
    sget-object v0, Llt/farmis/libraries/externalgps/nmea/NmeaParser;->sentenceParsers:Ljava/util/Map;

    new-instance v1, Llt/farmis/libraries/externalgps/nmea/NmeaParser$RMC;

    invoke-direct {v1, p0}, Llt/farmis/libraries/externalgps/nmea/NmeaParser$RMC;-><init>(Llt/farmis/libraries/externalgps/nmea/NmeaParser;)V

    const-string v2, "RMC"

    invoke-interface {v0, v2, v1}, Ljava/util/Map;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    .line 121
    sget-object v0, Llt/farmis/libraries/externalgps/nmea/NmeaParser;->sentenceParsers:Ljava/util/Map;

    new-instance v1, Llt/farmis/libraries/externalgps/nmea/NmeaParser$VTG;

    invoke-direct {v1, p0}, Llt/farmis/libraries/externalgps/nmea/NmeaParser$VTG;-><init>(Llt/farmis/libraries/externalgps/nmea/NmeaParser;)V

    const-string v2, "VTG"

    invoke-interface {v0, v2, v1}, Ljava/util/Map;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    return-void
.end method

.method static Latitude2Decimal(Ljava/lang/String;Ljava/lang/String;)F
    .locals 3

    const/4 v0, 0x2

    .line 19
    :try_start_0
    invoke-virtual {p0, v0}, Ljava/lang/String;->substring(I)Ljava/lang/String;

    move-result-object v1

    invoke-static {v1}, Ljava/lang/Float;->parseFloat(Ljava/lang/String;)F

    move-result v1

    const/high16 v2, 0x42700000    # 60.0f

    div-float/2addr v1, v2

    const/4 v2, 0x0

    .line 20
    invoke-virtual {p0, v2, v0}, Ljava/lang/String;->substring(II)Ljava/lang/String;

    move-result-object p0

    invoke-static {p0}, Ljava/lang/Float;->parseFloat(Ljava/lang/String;)F

    move-result p0

    add-float/2addr v1, p0

    const-string p0, "S"

    .line 21
    invoke-virtual {p1, p0}, Ljava/lang/String;->startsWith(Ljava/lang/String;)Z

    move-result p0
    :try_end_0
    .catch Ljava/lang/IndexOutOfBoundsException; {:try_start_0 .. :try_end_0} :catch_0

    if-eqz p0, :cond_0

    neg-float v1, v1

    :cond_0
    return v1

    :catch_0
    const/4 p0, 0x0

    return p0
.end method

.method static Longitude2Decimal(Ljava/lang/String;Ljava/lang/String;)F
    .locals 3

    const/4 v0, 0x3

    .line 32
    :try_start_0
    invoke-virtual {p0, v0}, Ljava/lang/String;->substring(I)Ljava/lang/String;

    move-result-object v1

    invoke-static {v1}, Ljava/lang/Float;->parseFloat(Ljava/lang/String;)F

    move-result v1

    const/high16 v2, 0x42700000    # 60.0f

    div-float/2addr v1, v2

    const/4 v2, 0x0

    .line 33
    invoke-virtual {p0, v2, v0}, Ljava/lang/String;->substring(II)Ljava/lang/String;

    move-result-object p0

    invoke-static {p0}, Ljava/lang/Float;->parseFloat(Ljava/lang/String;)F

    move-result p0

    add-float/2addr v1, p0

    const-string p0, "W"

    .line 34
    invoke-virtual {p1, p0}, Ljava/lang/String;->startsWith(Ljava/lang/String;)Z

    move-result p0
    :try_end_0
    .catch Ljava/lang/IndexOutOfBoundsException; {:try_start_0 .. :try_end_0} :catch_0

    if-eqz p0, :cond_0

    neg-float v1, v1

    :cond_0
    return v1

    :catch_0
    const/4 p0, 0x0

    return p0
.end method

.method static parseFloat(Ljava/lang/String;)F
    .locals 0

    .line 45
    :try_start_0
    invoke-static {p0}, Ljava/lang/Float;->parseFloat(Ljava/lang/String;)F

    move-result p0
    :try_end_0
    .catch Ljava/lang/NumberFormatException; {:try_start_0 .. :try_end_0} :catch_0

    return p0

    :catch_0
    const/4 p0, 0x0

    return p0
.end method


# virtual methods
.method public parse(Ljava/lang/String;)Llt/farmis/libraries/externalgps/GPSLocation;
    .locals 3

    const-string v0, "$"

    .line 129
    invoke-virtual {p1, v0}, Ljava/lang/String;->startsWith(Ljava/lang/String;)Z

    move-result v0

    if-eqz v0, :cond_2

    const/4 v0, 0x1

    .line 130
    invoke-virtual {p1, v0}, Ljava/lang/String;->substring(I)Ljava/lang/String;

    move-result-object p1

    const-string v0, ","

    .line 131
    invoke-virtual {p1, v0}, Ljava/lang/String;->split(Ljava/lang/String;)[Ljava/lang/String;

    move-result-object p1

    const/4 v0, 0x0

    .line 132
    aget-object v0, p1, v0

    .line 135
    invoke-virtual {v0}, Ljava/lang/String;->length()I

    move-result v1

    const/4 v2, 0x5

    if-ne v1, v2, :cond_0

    const/4 v1, 0x2

    .line 136
    invoke-virtual {v0, v1}, Ljava/lang/String;->substring(I)Ljava/lang/String;

    move-result-object v0

    .line 140
    :cond_0
    :try_start_0
    sget-object v1, Llt/farmis/libraries/externalgps/nmea/NmeaParser;->sentenceParsers:Ljava/util/Map;

    invoke-interface {v1, v0}, Ljava/util/Map;->containsKey(Ljava/lang/Object;)Z

    move-result v1

    if-eqz v1, :cond_1

    .line 141
    sget-object v1, Llt/farmis/libraries/externalgps/nmea/NmeaParser;->sentenceParsers:Ljava/util/Map;

    invoke-interface {v1, v0}, Ljava/util/Map;->get(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Llt/farmis/libraries/externalgps/nmea/NmeaParser$SentenceParser;

    iget-object v1, p0, Llt/farmis/libraries/externalgps/nmea/NmeaParser;->position:Llt/farmis/libraries/externalgps/GPSLocation;

    invoke-interface {v0, p1, v1}, Llt/farmis/libraries/externalgps/nmea/NmeaParser$SentenceParser;->parse([Ljava/lang/String;Llt/farmis/libraries/externalgps/GPSLocation;)Z

    .line 143
    :cond_1
    iget-object p1, p0, Llt/farmis/libraries/externalgps/nmea/NmeaParser;->position:Llt/farmis/libraries/externalgps/GPSLocation;

    invoke-virtual {p1}, Llt/farmis/libraries/externalgps/GPSLocation;->updatefix()V
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    goto :goto_0

    :catch_0
    move-exception p1

    .line 145
    invoke-virtual {p1}, Ljava/lang/Exception;->printStackTrace()V

    .line 148
    :cond_2
    :goto_0
    iget-object p1, p0, Llt/farmis/libraries/externalgps/nmea/NmeaParser;->position:Llt/farmis/libraries/externalgps/GPSLocation;

    return-object p1
.end method
